function PatchTestQ4
clc
%close all
addpath('..');
addpath('../..');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mesh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nodes = [ 0 0;
    1 0;
    1 1;
    0 1 ];
% connectivities = [ 1 2 3;
%     1 3 4];
connectivities = [ 1 2 3 4];
mesh = createMesh(nodes,connectivities);
%mesh.printMyself();
%plotMesh(mesh);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conditions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
du = 2;
% lambda = [linspace(0,1,21) linspace(1,0,21) ...
%     linspace(0,2,21)];
lambda = [linspace(0,1,11)];
constraint = [  1 0 0 0.0 0.0;
    2 0 0 du 0.0;
    3 0 1 du 0.0;
    4 0 1 0.0 0.0   ];
setConstraints(mesh,constraint);
% c1 = fem2.Constraint([0 0]);
% c2 = fem2.Constraint([1 0]);
% c3 = fem2.Constraint([0 1]);
% c4 = fem2.Constraint([0 1]);
% meshUtil = fem2.MeshUtilities(mesh);
% mesh.setConstraint(0

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% element declaration; custom section
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
M = fem2.Model(mesh);
nf = mesh.countFaces();
E = 2;
nu = 0.3;
C = C_plane_strain(E,nu);
for i=1:nf
    e = fem2.MatlabStructuralElement(mesh.getFace(i-1));
    M.addElement(e);
    %create struct to contain element state variables
    es = createElementContainer();
    es.constitutiveMatrix = C;
    elements(i) = es;
end
elements = Initialize(elements,M);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% solve
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
postProcessInfo.infoList = {'resistant force',...
    'stress at Gauss points'};
% postProcessInfo.infoParam = {[1 4],[1 2]};
postProcessInfo.infoParam = {[1 4],[1]};

[elements,output] = solving_strategy_static_2(elements,M,...
    lambda,50,1e-6,postProcessInfo);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% post process
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
res_node_1(:,:) = -output.resistant_force(:,1,:)
delta = lambda*du;
plot(delta,res_node_1);

output.stress_gp

rmpath('..');
rmpath('../..');
end
